home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n4.arc / SETS.MTH < prev    next >
Text File  |  1990-09-13  |  845b  |  41 lines

  1. intersect: aSet
  2.     "Return the intersection of two sets"
  3.  
  4.  
  5.     ^ self select: [: anObject |
  6.             aSet includes: anObject
  7.     ].
  8.  
  9.  
  10. isSubsetOf: aSet
  11.     "Return true if self is a subset of aSet"
  12.  
  13.     ^ (self select: [: anObject |
  14.             aSet includes: anObject
  15.         ]) size = (self size).
  16.  
  17.  
  18. notIntersect: aSet
  19.     "Return the set of everything but
  20.      the intersection of self and aSet"
  21.  
  22.     ^ (self select: [: anObject |
  23.         (aSet includes: anObject) not
  24.     ]) union: (aSet select: [: anObject |
  25.         (self includes: anObject) not
  26.     ]).
  27.  
  28.  
  29. union: aSet
  30.     "Return the union of two sets"
  31.  
  32.     | newSet |
  33.  
  34.     newSet := Set new.
  35.     self do:    [: anObject |
  36.         newSet add: anObject
  37.     ].
  38.     aSet do:    [: anObject |
  39.         newSet add: anObject
  40.     ].
  41.     ^ newSet.